package com.example.canatest.config;

import com.alibaba.otter.canal.protocol.CanalEntry;
import com.xpand.starter.canal.annotation.*;

/**
 * @author chen.qian
 * @date 2018/3/19
 */
@CanalEventListener
public class MyEventListener {

/*    //添加操作被监听到
    @InsertListenPoint
    public void onEvent(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
        rowData.getAfterColumnsList().forEach((c) -> System.err.println("By--Annotation: " + c.getName() + " ::   " + c.getValue()));
    }
    //修改操作被监听到
    @UpdateListenPoint
    public void onEvent1(CanalEntry.RowData rowData) {
        System.err.println("UpdateListenPoint");
        rowData.getAfterColumnsList().forEach((c) -> System.err.println("By--Annotation: " + c.getName() + " ::   " + c.getValue()));
    }
    //删除操作被监听到
    @DeleteListenPoint
    public void onEvent3(CanalEntry.EventType eventType) {
        System.err.println("DeleteListenPoint");
    }*/

    //全能型 监听所有
    @ListenPoint(destination = "example",
            schema = "gmall_product",
            table = {"base_trademark", "base_category1"},
            eventType = {
            CanalEntry.EventType.UPDATE,
            CanalEntry.EventType.INSERT,
            CanalEntry.EventType.DELETE
               })
    public void onEvent4(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {



        //C : Map  name Value
        rowData.getAfterColumnsList().forEach((c) ->
                System.err.println(c.getName() + " ::   " + c.getValue()));



    }
}
